const fs=require('fs');

var path='./04 node中的fs模块';

//流的方式读取文件
var readStream=fs.createReadStream(path+'/input.txt');

var str='';//保存数据
var count=0;
readStream.on('data',function(chunk){
    console.log(`第${count+1}次获取到的数据${chunk.length}`);
    str+=chunk;
    count++;
});

//读取完成回调
readStream.on('end',function(){
    console.log(count);
    console.log(str);
});

readStream.on('error',function(error){
    if(error)throw error;
});
